package com.lhj.xxsc.member.web;

import com.xxsc.common.utils.R;
import com.lhj.xxsc.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;


/**
 * @author 罗惠江
 * @version 1.0
 * @email 1511619294@qq.com
 * @date 2021/1/8 17:21
 */
@Controller
public class MemberWebController {

	@Autowired
	OrderFeignService orderFeignService;

	@GetMapping("/memberOrder.html")
	public String memberOrderPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, Model model) {
		// 可以获取支付宝的数据

		// 查询出当前登录的用户的所有订单数据
		System.out.println("查看订单");
		Map<String, Object> page = new HashMap<>();
		page.put("page", pageNum.toString());
		R r = orderFeignService.listWithItem(page);
		if (r.getCode() == 0) {
			System.out.println(r);
			model.addAttribute("orders", r);
//			System.out.println(r.toString());
		}
		return "orderList";
	}
}
